/**
 * 功能描述 列表
 */
define(function (require, exports, module) {
	var Grid = require("grid"); 	
	var aw = require("ajaxwrapper");
	var Dialog = require("dialog");
	var store =require("store");
	var activeUser = store.get("user");	
	
	var intentionregister_Props = require("../constant/returnvisit_Props");
	var intentionRegisterGrid_Events = require("../handler/ReturnvisitGrid_Events");

    var instance = {
        initComponent: function (params, widget) {
        	var grid = new Grid({
                parentNode : ".J-grid",
                url : "api/travelcontract/query",
                params : function(){
                		var obj={
                				"signUpDate":widget.get("subnav").getValue("checkInDate").start,
                				"signUpDateEnd":widget.get("subnav").getValue("checkInDate").end,
                				"visitStatus":widget.get("subnav").getValue("status"),
                				"servicePoint":activeUser.servicePoint.pkServicePoint,
                				"status":"Valid",
    	     					fetchProperties:intentionregister_Props.gridFetchProperties
                		}
                		return obj;
                },
                model : {
                    columns : [{
                        name : "contactNo",
                        label : "合同号",
                    },{
                        name : "member.personalInfo.name",
                        label : "会员",
                    },{
                        name : "member.personalInfo.mobilePhone",
                        label : "联系电话",
                    },{
                        name : "productRule.product.name",
                        label : "签约产品",
                    },{
                        name : "productType.name",
                        label : "产品类型",
                    },{
                        name : "number",
                        label : "购买份数",
                    },{
                	    name : "signUpDate",
                        label : "签约日期",
                        format :"date",
 					    formatparams:{
 						  mode:"YYYY-MM-DD"
 					    }
                    },{
                        name : "visitStatus.value",
                        label : "状态",
                        format :function(value,row){
                        	if(row.visitStatus==null){
                        		return "待回访"
                        	}else if(row.visitStatus.key == "NoVisit"){
                        		return "待回访"
                        	}else{
                        		return "已回访"
                        	}
                        }
                    },{
                        name : "show",
                        label : "操作",
    					format:"button",
						formatparams:[{
							id:"visit",
							text:"回访",
							handler:function(index,data,rowEle){
								if(data.visitStatus != null && data.visitStatus.key == "Visit"){
									Dialog.alert({
						    			id: "questionDialog",
										content : "该状态下不能在进行回访了！",
									});
									return false;
								}else{
									intentionRegisterGrid_Events.showDetail(widget,data,false,"Return");
								}
							}
						},{
							id:"show",
							text:"查看",
							handler:function(index,data,rowEle){
								intentionRegisterGrid_Events.showDetail(widget,data,true,"Return");
							}
						}]
                    }]
                }
            });
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
